package com.xintonghua.bussiness.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xintonghua.base.adapter.BaseAdapter;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.bean.StaffBean;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/1/13.
 * 包名：com.xintonghua.hongyi.adapter
 */

public class PositionAdapter extends BaseAdapter<StaffBean, PositionAdapter.ProductViewHolder> {


    public PositionAdapter(Activity mActivity, List<StaffBean> list) {
        super(mActivity, list);
    }

    @Override
    public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.adapter_position, parent, false);
        return new ProductViewHolder(view);
    }


    @Override
    public void onBindViewHolder(ProductViewHolder holder, final int position) {
        holder.tvPositionName.setText(list.get(position).getName());
        holder.tvPositionName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EventBus.getDefault().post(list.get(position));
                mActivity.finish();
            }
        });
    }

    class ProductViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_position_name)
        TextView tvPositionName;

        public ProductViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
